<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<meta name="keywords" content="关键字,keywords" />
		<meta name="description" content="描述">
		<title>润泉</title>
		<link rel="stylesheet" href="__CSS__/bootstrap.css" />
		<link rel="stylesheet" href="__CSS__/style.css" />
		<link rel="stylesheet" href="__CSS__/wwstyle.css" />
		<script type="text/javascript" src="__JS__/jquery-2.1.0.js"></script>
		<script type="text/javascript" src="__JS__/bootstrap.min.js"></script>
	</head>
	<style>
		.form-control {
			height: 33px;
		}
	</style>

	<body>
		
		<div class="container wrapper-content animated fadeInRight">
			<div class="row" style="padding: 0 -20px;">
				<div class="col-sm-12" style="padding: 0;">
					<div class="ibox float-e-margins">
						<div class="ibox-title">
							<h5>添加角色</h5>
						</div>
						<div class="ibox-content">
							<form class="form-horizontal" name="userAdd" id="userAdd" method="post" action="/admin/user/useradd.html">
								<div class="form-group">
									<label class="col-sm-3 control-label">角色名称：</label>
									<div class="input-group col-sm-4">
										<input type="hidden" name="id" value="{present name='$data'}{$data.id}{/present}" id="id">
										<input id="username" type="text" class="form-control" name="username" value="{present name='$data'}{$data.title}{/present}">
									</div>
								</div>
								<div class="hr-line-dashed"></div>
								
								<div class="form-group">
									<label class="col-sm-3 control-label">状&nbsp;态：</label>
									<div class="col-sm-6">
										<div class="switchery-radio" style="padding-top: 8px;">
											<input type="checkbox" id="status" name="status" value="1" class="js-switch" checked>
											默认开启
										</div>
									</div>
								</div>
								<div class="hr-line-dashed"></div>
								<div class="form-group">
									<div class="col-sm-4 col-sm-offset-3">
										<button class="btn btn-primary" id="but" type="button"><i class="fa fa-save"></i> 保存</button>&nbsp;&nbsp;&nbsp;
										<a class="btn btn-danger" href="javascript:history.go(-1);"><i class="fa fa-close"></i> 返回</a>
									</div>
								</div>
							</form>
						</div>
					</div>

				</div>
			</div>
		</div>
		
		<script>
			$("#but").click(function () {
				var title = $("#username").val();
				var id = $("#id").val();
                var status = '';
				if ($("#status").is(":checked")){
                    status = $("#status").val();
				}else {
                    status = 0;
				}
				if (title == "" || title == null){
				    alert("角色名不能为空！");
				    return false;
				}
				$.get("{:url('role/doAddRole')}",{title:title,status:status,id:id},function (data) {
				    alert(data.msg);
                    if (data.code == 1){
                        javascript:history.go(-1);
                    }
                })

            });
		</script>
	</body>

</html>